package com.comando.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.CascadeType;

import org.hibernate.annotations.GenericGenerator;

/**
 * UserMemberT entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user_member_t", catalog = "qunar", uniqueConstraints = @UniqueConstraint(columnNames = "USER_ID"))
public class UserMemberT implements java.io.Serializable {

	// Fields

	private Integer userMemberId;
	private UserT userT;
	private GroupT groupT;
	private Integer score;
	private Integer money;
	private String state;

	// Constructors

	/** default constructor */
	public UserMemberT() {
	}

	/** minimal constructor */
	public UserMemberT(GroupT groupT, Integer score, Integer money) {
		this.groupT = groupT;
		this.score = score;
		this.money = money;
	}

	/** full constructor */
	public UserMemberT(UserT userT, GroupT groupT, Integer score,
			Integer money, String state) {
		this.userT = userT;
		this.groupT = groupT;
		this.score = score;
		this.money = money;
		this.state = state;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "USER_MEMBER_ID", unique = true, nullable = false)
	public Integer getUserMemberId() {
		return this.userMemberId;
	}

	public void setUserMemberId(Integer userMemberId) {
		this.userMemberId = userMemberId;
	}

	//@OneToOne(fetch = FetchType.LAZY, mappedBy = "userMemberT")
	@OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "USER_ID")
	public UserT getUserT() {
		return this.userT;
	}

	public void setUserT(UserT userT) {
		this.userT = userT;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "GROUP_ID", nullable = false)
	public GroupT getGroupT() {
		return this.groupT;
	}

	public void setGroupT(GroupT groupT) {
		this.groupT = groupT;
	}

	@Column(name = "SCORE", nullable = false)
	public Integer getScore() {
		return this.score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	@Column(name = "MONEY", nullable = false)
	public Integer getMoney() {
		return this.money;
	}

	public void setMoney(Integer money) {
		this.money = money;
	}

	@Column(name = "STATE", length = 2)
	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

}